﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Data;

namespace ShenLan.Common
{
    public class XmlHandler
    {
        /// <summary>
        /// 根据节点名称,获取节点
        /// </summary>
        /// <param name="path">xml路径</param>
        /// <param name="nodeName">节点名称</param>
        /// <returns></returns>
        public static XmlNode GetXmlNode(string path, string nodeName)
        {
            try
            {
                XmlNode node;
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                node = doc.SelectSingleNode(nodeName);
                return node;
                //doc.LoadXml(path);                
            }
            catch { return null; }
        }

        public static bool SetXmlNode(string path, string nodeName)
        {
            try
            {
                XmlNode node;
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                node = doc.SelectSingleNode(nodeName);
                return true;                    
            }
            catch { return false; }
        }
    }
}